﻿using System;

using Microsoft.Xna.Framework.Graphics;

namespace Ah.Testudin.Game.Infrastructure
{
    public class TestudinServiceProvider : IServiceProvider
    {
        #region Private Member Variables

        private readonly IGraphicsDeviceService _graphicsDeviceService;

        #endregion

        #region Constructors

        public TestudinServiceProvider(
            IGraphicsDeviceService graphicsDeviceService)
        {
            if (graphicsDeviceService == null)
            {
                throw new ArgumentNullException("graphicsDeviceService");
            }

            _graphicsDeviceService = graphicsDeviceService;
        }

        #endregion

        #region IServiceProvider

        public object GetService(Type serviceType)
        {
            if (serviceType == typeof(IGraphicsDeviceService))
            {
                return _graphicsDeviceService;
            }

            throw new ArgumentException(
                string.Format(
                    "Type not found: {0}",
                    serviceType));
        }

        #endregion
    }
}
